function methodInfo(methodName,data){
	this.method=methodName
	this.data=data
}
let serverUrl=location.origin+'/v1'
 //let serverWebUrl='http://localhost:9001/v1';
// let serverUrl=serverWebUrl+'/v1';
let code_success=200;
var sensorServer={
	//向服务器法送数据
	postServerData:function(postUrl,postData){
		$.ajaxSettings.async = false;
		var url=postUrl;
		var serverResultData;
		var jsonData=JSON.stringify(postData)
		$.ajax({
			//请求类型，这里为POST
			type: 'POST', //你要请求的api的URL
			url: url , //是否使用缓存
			cache:false, //数据类型，这里我用的是json
			dataType: "json",
			contentType:"application/json;charset=utf-8",
			//必要的时候需要用JSON.stringify() 将JSON对象转换成字符串
			data: jsonData, //data: {key:value},
			//添加额外的请求头
			headers : {'Access-Control-Allow-Origin':'*',"token":window.localStorage.getItem("token")}, //请求成功的回调函数
			success: function(data){
				//函数参数 "data" 为请求成功服务端返回的数据
				// if (data.code==510){
				//     alert("重新登录！");
				//     open("./login.html");
				// }
				serverResultData= data.data;
			}
		});
		$.ajaxSettings.async = true;
		return serverResultData;
	},
	postServerDataSync:function(postUrl,postData){
		//   $.ajaxSettings.async = false;
		var url=postUrl;
		var serverResultData=false;
		var jsonData=JSON.stringify(postData)
		$.ajax({
			//请求类型，这里为POST
			type: 'POST', //你要请求的api的URL
			url: url , //是否使用缓存
			cache:false, //数据类型，这里我用的是json
			dataType: "json",
			contentType:"application/json;charset=utf-8",
			//必要的时候需要用JSON.stringify() 将JSON对象转换成字符串
			data: jsonData, //data: {key:value},
			//添加额外的请求头
			headers : {'Access-Control-Allow-Origin':'*',"token":window.localStorage.getItem("token")}, //请求成功的回调函数
			success: function(data){
				serverResultData= data.data;
				return  data.data;
			}
		});
		// $.ajaxSettings.async = true;
		return serverResultData;
	},
	//获取传感器数据 list
	getSensorList:function(postData){
		var url=serverUrl+"/sensor/list";
		$.ajaxSettings.async = false;
		return  sensorServer.postServerData(url,postData);
	},
	//获取基站定位显示
	getLocationList:function(postData){
		var url=serverUrl+"/Api/StationInfo.aspx";
		$.ajaxSettings.async = false;
		return  sensorServer.postServerData(url,postData);
	},
	//获取video  数据
	getVideoInfoList:function(postData){
		var url=serverUrl+"/video/list";
		$.ajaxSettings.async = false;
		return  sensorServer.postServerData(url,postData);
	},
	//修改传感器数据
	updateSensorInfo1:function (postData) {
		$.ajaxSettings.async = false;
		var url=serverUrl+"/sensor/update";
		return  sensorServer.postServerData(url,postData);
	},
	//新增传感器数据
	addSensorInfo:function (postData) {
		// var url=serUrl;
		// var postData=new methodInfo("AddSensor",jsonData)
		// jsonData=JSON.stringify(postData)
		// $.post(url,jsonData,function (data) {
		//     console.log(data);
		//     return data;
		// },'json')
		// return null;
		$.ajaxSettings.async = false;
		var url=serverUrl+"/sensor/addSensor";
		return  sensorServer.postServerData(url,postData);
	},
	delSensorInfo:function (postData) {
		$.ajaxSettings.async = false;
		var url=serverUrl+"/sensor/delete";
		return  sensorServer.postServerData(url,postData);
	},

	//获取LED  数据
	getLedList:function(postData){
		var url=serverUrl+"/led/list";
		$.ajaxSettings.async = false;
		return  sensorServer.postServerData(url,postData);
	},
	//获取LED 根据ID 数据
	getLedListByPid:function(postData){
		var url=serverUrl+"/led/list/pid";
		$.ajaxSettings.async = false;
		return  sensorServer.postServerDataSync(url,postData);
	},
	//新增LED
	addLedInfo:function (postData) {
		$.ajaxSettings.async = false;
		var url=serverUrl+"/led/add";
		return  sensorServer.postServerDataSync(url,postData);
	},
	//删除LED
	delLedInfo:function (postData) {
		$.ajaxSettings.async = false;
		var url=serverUrl+"/led/del";
		return  sensorServer.postServerData(url,postData);
	},
	//修改LED
	updateLedInfo:function (postData) {
		$.ajaxSettings.async = false;
		var url=serverUrl+"/led/update";
		return  sensorServer.postServerData(url,postData);
	},

	//获取传感器采集的数据
	getSensorDataListByPage:function (postData) {
		$.ajaxSettings.async = false;
		var url=serverUrl+"/sensorData/list";
		return  sensorServer.postServerData(url,postData);
	},
	//获取报警记录的数据
	getWarningListByPage:function (postData) {
		$.ajaxSettings.async = false;
		var url=serverUrl+"/warning/list";
		return  sensorServer.postServerData(url,postData);
	},
	updateWarningInfo:function (postData) {
		$.ajaxSettings.async = false;
		var url=serverUrl+"/warning/update";
		return  sensorServer.postServerData(url,postData);
	},
	//获取断网记录的数据
	getLogNetworkListByPage:function (postData) {
		$.ajaxSettings.async = false;
		var url=serverUrl+"/log/networkList";
		return  sensorServer.postServerData(url,postData);
	},
	//获取刷屏记录的数据
	getLogLedListByPage:function (postData) {
		$.ajaxSettings.async = false;
		var url=serverUrl+"/log/ledLogList";
		return  sensorServer.postServerData(url,postData);
	},
	getBatteryListByPage:function (postData) {
		$.ajaxSettings.async = false;
		var url=serverUrl+"/battery_info/list";
		return  sensorServer.postServerData(url,postData);
	},
	//删除 获取断网记录的数据
	deleteLogNetworkListByPage:function (postData) {
		$.ajaxSettings.async = false;
		var url=serverUrl+"/log/networkList/delete";
		return  sensorServer.postServerData(url,postData);
	},
	//删除一条告警记录
	deleteWarning:function (postData) {
		$.ajaxSettings.async = false;
		var url=serverUrl+"/warning/delete";
		return  sensorServer.postServerData(url,postData);
	},
	//修改最大报警值设置
	updateMaxSetting:function (postData) {
		$.ajaxSettings.async = false;
		var url=serverUrl+"/max_setting/update";
		return  sensorServer.postServerData(url,postData);
	},
	//修改最大报警值设置
	getMaxSetting:function (postData) {
		$.ajaxSettings.async = false;
		var url=serverUrl+"/max_setting/list";
		return  sensorServer.postServerData(url,postData);
	},
	//根据小时获取折线图数据
	getSensorDataListByHour:function (postData) {
		$.ajaxSettings.async = false;
		var url=serverUrl+"/sensorData/line/chart";
		var resultData=sensorServer.postServerData(url,postData);
		return  resultData;
	},
	//根据指定的地点获取 历史数据
	getSensorDataListByDate:function (postData) {
		$.ajaxSettings.async = false;
		var url=serverUrl+"/sensorData/list/byDate";
		var resultData=sensorServer.postServerData(url,postData);
		return  resultData;
	},
	//获取班报数据
	getSensorDataListByByBanci:function (postData) {
		$.ajaxSettings.async = false;
		var url=serverUrl+"/report/base/list";
		var resultData=sensorServer.postServerData(url,postData);
		return  resultData;
	},

	//获取班报模板
	getReportModeList:function (postData) {
		$.ajaxSettings.async = false;
		var url=serverUrl+"/report/model/list";
		var resultData=sensorServer.postServerData(url,postData);
		return  resultData;
	},

	//获取班报模板
	exportReportByModel:function (modelPath,day,banci) {
		$.ajaxSettings.async = false;
		var url=serverUrl+modelPath+"?day="+day+"&banci="+banci;
		open(url);
	},

	//ping ip 是否通讯
	ipConnect:function (postData) {
		// $.ajaxSettings.async = false;
		var url=serverUrl+"/sensor/ping";
		var resultData=sensorServer.postServerDataSync(url,postData);
		return  resultData;
	},
	getSensorByPid:function (postData) {
		// $.ajaxSettings.async = false;
		let url=serverUrl+"/sensor/getSensorByPid";
		let resultData=sensorServer.postServerData(url,postData);
		return  resultData;
	},
	//获取CAD图
	getCadBackgroundSvgFile(postData){
		let url=serverUrl+"/settings/getByAppkey";
		let resultData=sensorServer.postServerData(url,postData);
		return  resultData;
	},
	//获取系统配参数
	getSettingsByAppkey(postData){
		let url=serverUrl+"/settings/getByAppkey";
		let resultData=sensorServer.postServerData(url,postData);
		return  resultData;
	},
	//获得指定时间内按小时最大值
	getSensorDataLineChart(postData){
		let url=serverUrl+"/sensorData/line/chart";
		let resultData=sensorServer.postServerData(url,postData);
		return  resultData;
	},
	//获得最近的数据
	getSensorDataLately(postData){
		let url=serverUrl+"/sensorData/getSensorDataLately";
		let resultData=sensorServer.postServerData(url,postData);
		return  resultData;
	},
	//修改坐标
	updateCoordinate(postData){
		let url=serverUrl+"/led/updateCoordinate";
		let resultData=sensorServer.postServerData(url,postData);
		return  resultData;
	},
	//修改系统设置
	updateSettingsInfo:function (postData) {
		$.ajaxSettings.async = false;
		var url=serverUrl+"/settings/update";
		return  sensorServer.postServerData(url,postData);
	},
	//根据天获取折线图数据  最大值
	getSensorDataListByDay:function (postData) {
		$.ajaxSettings.async = false;
		var url=serverUrl+"/sensorData/line/chart1";
		var resultData=sensorServer.postServerData(url,postData);
		return  resultData;
	},
	//根据APP key 获取设置的Val
	getSettingsByAppKey:function(postData){
		let url=serverUrl+"/settings/getByAppkey";
		let resultData=sensorServer.postServerData(url,postData);
		return  resultData;
	},
	//获取系统维护人员类别
	getMaintainPersonList:function (postData) {
		$.ajaxSettings.async = false;
		var url=serverUrl+"/account/maintainPersonList";
		return  sensorServer.postServerData(url,postData);
	},
	//智能客服的接口 1=================================================================================
	getMinesList: function (postData) {
		$.ajaxSettings.async = false;
		let url = serverUrl + "/customerService/getMinesList";
		return sensorServer.postServerData(url, postData);
	},
}
